package com.fr.report.script.function;

import com.fr.report.script.Function;
import com.fr.report.script.Function.Type;
import com.fr.report.script.NormalFunction;
import com.fr.report.script.Primitive;

public class CODE extends NormalFunction
{
  public Object run(Object[] paramArrayOfObject)
  {
    if (paramArrayOfObject.length < 1)
      return Primitive.ERROR_NAME;
    Object localObject = paramArrayOfObject[0];
    if (localObject != null)
    {
      String str = (String)localObject;
      if (str.length() > 0)
        return new Integer(str.charAt(0));
    }
    return Primitive.ERROR_NAME;
  }

  public Function.Type getType()
  {
    return Function.TEXT;
  }

  public String getCN()
  {
    return "CODE(text): 计算文本串中第一个字符的数字代码。返回的代码对应于计算机使用的字符集。\nText:需要计算第一个字符代码的文本或单元格引用。\n示例:\nCODE(\"S\")等于83。\nCODE(\"Spreadsheet\")等于83。";
  }

  public String getEN()
  {
    return "CODE(text): Returns a numeric code for the first character in a text string. The returned code corresponds to the character set used by your computer.\nText is the text for which you want the code of the first character.\n\nExample:\n   CODE(\"S\") = 83\n   CODE(\"Spreadsheet\") = 83";
  }
}